<template>
  <div class="app-container">
    <el-form ref="form" :model="form" label-width="120px">
      <el-form-item label="餐桌编号">
        <el-input v-model="form.number" />
      </el-form-item>
      <el-form-item label="餐桌描述信息">
        <el-input v-model="form.description" />
      </el-form-item>
      <el-form-item label="状态">
        <el-select v-model="form.state">
          <el-option :value="false" label="空置"></el-option>
          <el-option :value="true" label="已占用"></el-option>
        </el-select>
      </el-form-item>
      <el-form-item>
        <el-button type="primary" @click="onSubmit">保存信息</el-button>
      </el-form-item>
    </el-form>
  </div>
</template>

<script>
import { getTable, saveTable } from '@/api/api-v1/table';

export default {
  data() {
    return {
      form: {
        state: false
      } 
    };
  },
  methods: {
    onSubmit() {
      saveTable(this.form).then(()=>{
        this.$message.success("保存信息成功")
      })
    },
    onCancel() {
      this.$message({
        message: 'cancel!',
        type: 'warning'
      });
    }
  },
  created() {
    if (this.$route.query.id) {
      getTable(this.$route.query.id).then(res => {
        this.form = res.data;
      });
    }
  }
};
</script>

<style scoped>
.line {
  text-align: center;
}
</style>
